<?php
Load::models('categorias','videos','subcategorias');
class GaleriaController extends AppController 
{
    
    public function index($page=1)
    {
        $this->nivel = 'categorias';
        $this->videos = Load::model('videos')->getAllVideosbyVisits($page);        
        $this->categorias = Load::model('categorias')->find();  
    }
    
    public function categoria($categoria_name,$page=1)
    {
        $this->categoria = $categoria_name;
        $this->nivel = 'subcategorias';
        $this->categorias = Load::model('categorias')->getByNombre($categoria_name);                        
        $this->videos = Load::model('videos')->getVideosByVisitsByCategoria($categoria_name,$page);                
    }
    
    public function subcategoria($subcategoria_name='',$page=1)
    {
        $this->subcategoria_name = $subcategoria_name;
        $this->nivel = 'final';
        $this->categorias = Load::model('subcategorias')->getByName($subcategoria_name); 
        $this->videos = Load::model('videos')->getVideosByVisitsBySubcategoria($subcategoria_name,$page);        
    }
        
    public function galeria($categoria_name='',$subcategoria_name='',$page=1)
    {
                        
            if($subcategoria_name != ''){  
                $this->nivel = 'final';
                $this->categorias = Load::model('subcategorias')->getByName($subcategoria_name);                
            }else if($categoria_name != ''){
                $this->nivel = 'subcategorias';
                $this->categorias = Load::model('categorias')->getByNombre($categoria_name);
            }
                        
    }
    
    
}